<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>


<div id="flightList" "class="section">

	<c:if test="${ flightList != null && empty flightList}">
	<h2>Flight List</h2>
	<tr>
		<td colspan="7">No flights found</td>
	</tr>
	</c:if>

	<c:if test="${!empty flightList}">
	<h2>Flight List</h2>	
	
	<table class="summary">
		<thead>
			<tr>
				<th>Flight Number</th>
				<th>Departing City</th>
				<th>Departing Date</th>
				<th>Departing Time</th>
				<th>Arriving City</th>
				<th>Arriving Date</th>
				<th>Arriving Time</th>
				
			<c:if test="${showStatus}">			
				<th>Status</th>
			</c:if>
				
			<c:if test="${showStatus == null}">
				<th>Seats Available</th>
			</c:if>
				
				
			</tr>
		</thead>
		<tbody>
			<c:forEach var="flight" items="${flightList}">
			<tr>
				<td>${flight.flightNumber}</td>
				<td>${flight.departingCity.name}</td>
				<td>${flight.formattedDepartureDate}</td>
				<td>${flight.departureTime}</td>
				<td>${flight.destinationCity.name}</td>				
				<td>${flight.formattedArrivingDate}</td>
				<td>${flight.formattedArrivingTime}</td>
				
				
				<c:if test="${showStatus}">
				<td>${flight.status}</td>
				</c:if>
				
				<c:if test="${showStatus == null}">				
				<td>${flight.seatAvailable}</td>				
				</c:if>
				

			</tr>
			</c:forEach>
		</tbody>
	</table>
	</c:if>


</div>